package com.qpkj.web.controller.oms;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qpkj.common.annotation.Log;
import com.qpkj.common.core.controller.BaseController;
import com.qpkj.common.core.domain.AjaxResult;
import com.qpkj.common.enums.BusinessType;
import com.qpkj.oms.domain.OmsComplementRecord;
import com.qpkj.oms.service.IOmsComplementRecordService;
import com.qpkj.common.utils.poi.ExcelUtil;
import com.qpkj.common.core.page.TableDataInfo;

/**
 * 补数记录Controller
 *
 * @author ruoyi
 * @date 2023-02-18
 */
@RestController
@RequestMapping("/oms/complement")
public class OmsComplementRecordController extends BaseController {
    @Autowired
    private IOmsComplementRecordService omsComplementRecordService;

    /**
     * 查询补数记录列表
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsComplementRecord omsComplementRecord) {
        startPage();
        List<OmsComplementRecord> list = omsComplementRecordService.selectOmsComplementRecordList(omsComplementRecord);
        return getDataTable(list);
    }

    /**
     * 导出补数记录列表
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:export')")
    @Log(title = "补数记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsComplementRecord omsComplementRecord) {
        List<OmsComplementRecord> list = omsComplementRecordService.selectOmsComplementRecordList(omsComplementRecord);
        ExcelUtil<OmsComplementRecord> util = new ExcelUtil<OmsComplementRecord>(OmsComplementRecord.class);
        util.exportExcel(response, list, "补数记录数据");
    }

    /**
     * 获取补数记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(omsComplementRecordService.selectOmsComplementRecordById(id));
    }

    /**
     * 新增补数记录
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:add')")
    @Log(title = "补数记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsComplementRecord omsComplementRecord) {
        return toAjax(omsComplementRecordService.insertOmsComplementRecord(omsComplementRecord));
    }

    /**
     * 修改补数记录
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:edit')")
    @Log(title = "补数记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsComplementRecord omsComplementRecord) {
        return toAjax(omsComplementRecordService.updateOmsComplementRecord(omsComplementRecord));
    }

    /**
     * 删除补数记录
     */
    @PreAuthorize("@ss.hasPermi('oms:complement:remove')")
    @Log(title = "补数记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(omsComplementRecordService.deleteOmsComplementRecordByIds(ids));
    }
}
